package com.qifan.alb2b.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.qifan.alb2b.action.back.param.HotelQueryParam;
import com.qifan.alb2b.action.back.param.RoomQueryParam;
import com.qifan.alb2b.dao.HotelInfoDao;
import com.qifan.alb2b.dao.RoomInfoDao;
import com.qifan.alb2b.domain.HotelInfoDomain;
import com.qifan.alb2b.domain.RoomInfoDomain;
import com.qifan.alb2b.exception.BusinessException;
import com.qifan.alb2b.util.DataGridModel;
import com.qifan.alb2b.util.Page;

@Service
public class RoomInfoService {
	private RoomInfoDao roomInfoDao;
	private HotelInfoDao hotelInfoDao;

	public void setHotelInfoDao(HotelInfoDao hotelInfoDao) {
		this.hotelInfoDao = hotelInfoDao;
	}

	public void setRoomInfoDao(RoomInfoDao roomInfoDao) {
		this.roomInfoDao = roomInfoDao;
	}
	
	public Page query(DataGridModel dgm,RoomQueryParam uqp){
		return roomInfoDao.query(dgm,uqp);
	}
	
	public Page queryAllHotel(DataGridModel dgm,HotelQueryParam uqp){
		return  hotelInfoDao.query(dgm, uqp);
	}
	
	public void getRoomInfoByHotelId(String [] ids){
		for(int i=0;i<ids.length;i++){
			RoomInfoDomain roomInfo = roomInfoDao.getRoomByHotelId(ids[i]);
			if(roomInfo!=null){
				throw new BusinessException("id为"+ids[i]+"的酒店有下属房间，请先删除房间后再删除酒店！");
			}
		}

	}
	
	public void add(RoomInfoDomain roomInfoDomain){
		roomInfoDao.add(roomInfoDomain);
	}
	
	public void update(RoomInfoDomain roomInfoDomain){
		roomInfoDao.update(roomInfoDomain);
	}
	
	public void delete(String[] ids){
		roomInfoDao.delete(ids);
	}
}
